package com.wontube.smr.dao.providers;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.FROM;
import static org.apache.ibatis.jdbc.SqlBuilder.LEFT_OUTER_JOIN;
import static org.apache.ibatis.jdbc.SqlBuilder.ORDER_BY;
import static org.apache.ibatis.jdbc.SqlBuilder.SELECT;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;

import com.wontube.core.dao.mybatis.QueryExample;
import com.wontube.core.dao.mybatis.provider.SqlProvider;



public final class BlogSqlProvider extends SqlProvider {
	public String listAllCatAndCount(QueryExample example) {
		BEGIN();
	

		SELECT("blog_category.category_name,t.mun as sort_index ");
		FROM("blog_category");
		LEFT_OUTER_JOIN("(select category,count(category) as mun from blog  where  status=1  group by category ) as t on t.category = blog_category.category_name");

		applyWhere(example, false);

		if (example != null && example.getOrderByClause() != null) {
			ORDER_BY(example.getOrderByClause());
		}
		String sql=SQL();
		return sql;
	}


}
